﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GWModflow.FileLayers
{
    public class PRiver : Package
    {
        public PRiver()
        {
            this._fileType = FileType.RIV;

            this.Fname = "solution.riv";
            this.Nunit = 42;

        }





        int _MXACT;

        /// <summary>
        /// 最大活动河流数目
        /// </summary>
        public int MXACT
        {
            get { return _MXACT; }
            set { _MXACT = value; }
        }


        int _IRIVCB=102;

        /// <summary>
        /// cell by cell 标志位 和 unit number
        /// </summary>
        public int IRIVCB
        {
            get { return _IRIVCB; }
            set { _IRIVCB = value; }
        }


        //string _Option;

        //public string Option
        //{
        //    get { return _Option; }
        //    set { _Option = value; }
        //}





        List<SPRiver> _stressPeriodRiver = new List<SPRiver>();

        public List<SPRiver> StressPeriodRiver
        {
            get { return _stressPeriodRiver; }

        }





        public override void WriteFile(string path)
        {
            string content = "# HuanAnKeJi RIV File" + "\r\n";
            content += this.MXACT + "  " + this.IRIVCB + "\r\n";
            string str = "";
            foreach (SPRiver sp in StressPeriodRiver)
            {
                str += sp.ITMP + "  " + sp.NP + "\r\n";
                if (sp.ITMP < 0)
                {
                }
                else
                {
                    //str += sp.ITMP + "  " + sp.NP + "\r\n";
                    string str1 = "";
                    for (int i = 0; i < sp.RiverData.Count; i++)
                    {
                        str1 += string.Format("{0,10}", sp.RiverData[i].Layer) + " " + string.Format("{0,10}", sp.RiverData[i].Row) + " " + string.Format("{0,10}", sp.RiverData[i].Column) + " " +
                                string.Format("{0,10}", sp.RiverData[i].Value) + " " + string.Format("{0,10}", sp.RiverData[i].Value2) + " " + string.Format("{0,10}", sp.RiverData[i].Value3) + "\r\n";
                    }
                    str += str1;
                }
            }
            content += str;
            string fname = path + this.Fname;
            FXnaInfrastructure.FileHelper.WriteFile(fname, content);
        }


    }
}
